package com.jams.goodox.activity.serve.headhunter;

import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.jams.goodox.BaseActivity;
import com.jams.goodox.R;
import com.jams.goodox.activity.mine.view.KindredView;
import com.jams.goodox.adapter.CustomPagerAdapter;
import com.jams.goodox.constant.Constant;
import com.jams.goodox.utils.Utils;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * 企业招聘首页
 * create by 顾佳佳 on 2017/05/16
 */
public class CompanyRecruitActivity extends BaseActivity {

    @Bind(R.id.kindredView)
    KindredView kindredView;
    @Bind(R.id.viewPager)
    ViewPager viewPager;

    private ResumeFragment resumeFragment;
    private JobListFragment jobListFragment;

    private List<Fragment> fragmentList;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_company_recruit;
    }

    @Override
    protected void init() {
        setTitleVisibility(false);
        fragmentList = new ArrayList<>(2);
        resumeFragment = ResumeFragment.newInstance();
        jobListFragment = JobListFragment.newInstance();
        fragmentList.add(resumeFragment);
        fragmentList.add(jobListFragment);
        viewPager.setAdapter(new CustomPagerAdapter(getSupportFragmentManager(), fragmentList));

        viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                kindredView.setFocus(mContext, position);
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
        kindredView.addKindredClickListener(new KindredView.KindredClickListener() {
            @Override
            public void addKindredClickListener(int position) {
                viewPager.setCurrentItem(position);
            }
        });
        Utils.doFunctionIsOpen(this, Constant.AppFunctionName.HEADER_HUNTER,R.string.first_in_header);
    }

    @OnClick({R.id.back, R.id.iv_connecter_info})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.iv_connecter_info:
                qStartActivity(JobConnecterEditActivity.class);
                break;
        }
    }
}
